//
//  WHMsgHeaderView.m
//  SquirrelSeller
//
//  Created by 邓伟浩 on 2019/1/7.
//  Copyright © 2019 邓伟浩. All rights reserved.
//

#import "WHMsgHeaderView.h"

@interface WHMsgHeaderView ()

@property (nonatomic, strong) UIImageView *backImageView;

@property (nonatomic, strong) UIView *countBackView;

@property (nonatomic, strong) UIView *verGap;
@property (nonatomic, strong) UIView *horGap;

@property (nonatomic, strong) UILabel *msgSendTipLabel;
@property (nonatomic, strong) UILabel *msgSendCountLabel;

@property (nonatomic, strong) UILabel *wxSendTipLabel;
@property (nonatomic, strong) UILabel *wxSendCountLabel;

@property (nonatomic, strong) UILabel *monthSendTipLabel;
@property (nonatomic, strong) UILabel *monthSendCountLabel;

@property (nonatomic, strong) UILabel *remainTipLabel;
@property (nonatomic, strong) UILabel *remainCountLabel;

@end

@implementation WHMsgHeaderView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = KWhiteColor;
        [self setUpMsgHeaderView];
    }
    return self;
}

- (void)setUpMsgHeaderView {
    self.clipsToBounds = YES;
    [self addSubview:({
        _backImageView = [[UIImageView alloc] init];
        _backImageView.image = IMAGE_NAMED(@"msg_count_back");
        _backImageView.contentMode = UIViewContentModeScaleAspectFill;
        _backImageView;
    })];
    [_backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(self);
    }];
    
    [self addSubview:({
        _countBackView = [[UIView alloc] init];
        _countBackView;
    })];
    [_countBackView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(self);
        make.top.mas_equalTo(self.mas_top).offset(kTopHeight);
        make.height.mas_equalTo(kRealwidth(315));
    }];
    
    [_countBackView addSubview:({
        _verGap = [[UIView alloc] init];
        _verGap.backgroundColor = CLineColor;
        _verGap;
    })];
    [_verGap mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(0.5);
        make.centerX.mas_equalTo(_countBackView.mas_centerX);
        make.top.mas_equalTo(_countBackView.mas_top).offset(kRealwidth(15));
        make.bottom.mas_equalTo(_countBackView.mas_bottom).offset(-kRealwidth(15));
    }];
    [_countBackView addSubview:({
        _horGap = [[UIView alloc] init];
        _horGap.backgroundColor = CLineColor;
        _horGap;
    })];
    [_horGap mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(0.5);
        make.centerY.mas_equalTo(_countBackView.mas_centerY);
        make.width.mas_equalTo(KScreenWidth-2*kRealwidth(15));
        make.centerX.mas_equalTo(_countBackView.mas_centerX);
    }];

    [_countBackView addSubview:({
        _msgSendTipLabel = [[UILabel alloc] init];
        _msgSendTipLabel.text = @"短信发送成功";
        _msgSendTipLabel.textColor = KWhiteColor;
        _msgSendTipLabel.font = SYSTEMFONT(kRealwidth(15));
        _msgSendTipLabel;
    })];
    [_msgSendTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_countBackView.mas_top).offset(kRealwidth(45));
        make.height.mas_equalTo(kRealwidth(15));
        make.centerX.mas_equalTo(_countBackView.mas_centerX).multipliedBy(0.5);
    }];
    
    [_countBackView addSubview:({
        _msgSendCountLabel = [[UILabel alloc] init];
        _msgSendCountLabel.text = @"0";
        _msgSendCountLabel.textColor = KWhiteColor;
        _msgSendCountLabel.font = SYSTEMFONT(kRealwidth(24));
        _msgSendCountLabel.adjustsFontSizeToFitWidth = YES;
        _msgSendCountLabel.textAlignment = NSTextAlignmentCenter;
        _msgSendCountLabel;
    })];
    [_msgSendCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_msgSendTipLabel.mas_bottom).offset(kRealwidth(15));
        make.height.mas_equalTo(kRealwidth(24));
        make.centerX.mas_equalTo(_msgSendTipLabel.mas_centerX);
        make.width.mas_equalTo(_countBackView.mas_width).multipliedBy(0.4);
    }];
    
    [_countBackView addSubview:({
        _wxSendTipLabel = [[UILabel alloc] init];
        _wxSendTipLabel.text = @"微信发送成功";
        _wxSendTipLabel.textColor = KWhiteColor;
        _wxSendTipLabel.font = SYSTEMFONT(kRealwidth(15));
        _wxSendTipLabel;
    })];
    [_wxSendTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_countBackView.mas_top).offset(kRealwidth(45));
        make.height.mas_equalTo(kRealwidth(15));
        make.centerX.mas_equalTo(_countBackView.mas_right).multipliedBy(0.75);
    }];
    
    [_countBackView addSubview:({
        _wxSendCountLabel = [[UILabel alloc] init];
        _wxSendCountLabel.text = @"0";
        _wxSendCountLabel.textColor = KWhiteColor;
        _wxSendCountLabel.font = SYSTEMFONT(kRealwidth(24));
        _wxSendCountLabel.adjustsFontSizeToFitWidth = YES;
        _wxSendCountLabel.textAlignment = NSTextAlignmentCenter;
        _wxSendCountLabel;
    })];
    [_wxSendCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_wxSendTipLabel.mas_bottom).offset(kRealwidth(15));
        make.height.mas_equalTo(kRealwidth(24));
        make.centerX.mas_equalTo(_wxSendTipLabel.mas_centerX);
        make.width.mas_equalTo(_countBackView.mas_width).multipliedBy(0.4);
    }];
    
    [_countBackView addSubview:({
        _monthSendTipLabel = [[UILabel alloc] init];
        _monthSendTipLabel.text = @"本月发送成功";
        _monthSendTipLabel.textColor = KWhiteColor;
        _monthSendTipLabel.font = SYSTEMFONT(kRealwidth(15));
        _monthSendTipLabel;
    })];
    [_monthSendTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_horGap.mas_bottom).offset(kRealwidth(35));
        make.height.mas_equalTo(kRealwidth(15));
        make.centerX.mas_equalTo(_countBackView.mas_centerX).multipliedBy(0.5);
    }];
    
    [_countBackView addSubview:({
        _monthSendCountLabel = [[UILabel alloc] init];
        _monthSendCountLabel.text = @"0";
        _monthSendCountLabel.textColor = KWhiteColor;
        _monthSendCountLabel.font = SYSTEMFONT(kRealwidth(24));
        _monthSendCountLabel.adjustsFontSizeToFitWidth = YES;
        _monthSendCountLabel.textAlignment = NSTextAlignmentCenter;
        _monthSendCountLabel;
    })];
    [_monthSendCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_monthSendTipLabel.mas_bottom).offset(kRealwidth(15));
        make.height.mas_equalTo(kRealwidth(24));
        make.centerX.mas_equalTo(_monthSendTipLabel.mas_centerX);
        make.width.mas_equalTo(_countBackView.mas_width).multipliedBy(0.4);
    }];
    
    [_countBackView addSubview:({
        _remainTipLabel = [[UILabel alloc] init];
        _remainTipLabel.text = @"套餐剩余";
        _remainTipLabel.textColor = KWhiteColor;
        _remainTipLabel.font = SYSTEMFONT(kRealwidth(15));
        _remainTipLabel;
    })];
    [_remainTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_horGap.mas_bottom).offset(kRealwidth(35));
        make.height.mas_equalTo(kRealwidth(15));
        make.centerX.mas_equalTo(_countBackView.mas_right).multipliedBy(0.75);
    }];
    
    [_countBackView addSubview:({
        _remainCountLabel = [[UILabel alloc] init];
        _remainCountLabel.text = @"0";
        _remainCountLabel.textColor = KWhiteColor;
        _remainCountLabel.font = SYSTEMFONT(kRealwidth(24));
        _remainCountLabel.adjustsFontSizeToFitWidth = YES;
        _remainCountLabel.textAlignment = NSTextAlignmentCenter;
        _remainCountLabel;
    })];
    [_remainCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_remainTipLabel.mas_bottom).offset(kRealwidth(15));
        make.height.mas_equalTo(kRealwidth(24));
        make.centerX.mas_equalTo(_remainTipLabel.mas_centerX);
        make.width.mas_equalTo(_countBackView.mas_width).multipliedBy(0.4);
    }];
}

- (void)setMsgModel:(WHMsgModel *)msgModel {
    _msgModel = msgModel;
    _msgSendCountLabel.text = msgModel.shortMessage;
    _monthSendCountLabel.text = msgModel.monthShortMessage;
    _wxSendCountLabel.text = msgModel.wxNumber;
    _remainCountLabel.text = msgModel.surplusMessage;
    
}

@end
